# encoding: utf-8
from flask_marshmallow import base_fields

from flask_restplus_patched import ModelSchema
from app.modules.common.schemas import BaseSchema
from .models import AppInfo


class AppBaseSchema(ModelSchema):
    class Meta:
        model = AppInfo
        fields = (
            'id',
            'app_name',
            'host',
            'http_port',
            'jmx_port',
            'agent_port',
            'app_type',
            'entrance_id',
            'entrance_type',
            'current_status',
            'expect_status',
            'error_desc',
            'env_name',
            'zone_code',
            'group',
            'update_time',
            'cloudlink_status',
            'dubbo_status',
            'is_resource',
            'is_overtime',
        )


class AppListSchema(BaseSchema):
    data = base_fields.Nested(
        AppBaseSchema,
        many = True
    )

    class Meta:
        fields = BaseSchema.Meta.fields + (
            'data',
        )
